import {
    SewerGetQueryData,
    SewerGetQueryModelData,
    SewerAddData,
    SewerEditData,
    SewerEditRollback,
    SewerDelteleData
  } from '@/services/municipal';
  
  export default {
    namespace: 'pipingRoad',
    state: {
      list          : null,
      StatisticList : null
    },
  
    effects: {

      *fetchList({ payload, callback }, { call, put }) {
        const response = yield call(SewerGetQueryModelData, payload);
  
        if (response.data) {
          yield put({
            type: 'list',
            payload: {
                response:response,
                data:response.data
            },
          });
        } else {
          if (callback) callback(response);
        }
      },


      *fetchStatisticList({ payload, callback }, { call, put }) {
        const response = yield call(SewerGetQueryData, payload);
  
        if (response.data) {
          yield put({
            type: 'StatisticList',
            payload: {
                response:response,
                data:response.data
            },
          });
        } else {
          if (callback) callback(response);
        }
      },
      *fetchSewerAddData({ payload, callback }, { call, put }) {
        const response = yield call(SewerAddData, payload);
        if (callback) callback(response);
      },
      *fetchSewerEditData({ payload, callback }, { call, put }) {
        const response = yield call(SewerEditData, payload);
        if (callback) callback(response);
      },
      *fetchSewerEditRollback({ payload, callback }, { call, put }) {
        const response = yield call(SewerEditRollback, payload);
        if (callback) callback(response);
      },
      *fetchSewerDelteleData({ payload, callback }, { call, put }) {
        const response = yield call(SewerDelteleData, payload);
        if (callback) callback(response);
      },
      

    },
  
    reducers: {
 
      list(state, action) {
       
        action.payload.data.push({
            yf:'合计',
            gdst     : action.payload.response.sum_gdst,
            qlyn     : action.payload.response.sum_qlyn,
            stgdgg110: action.payload.response.sum_stgdgg110,
            stgdgg225: action.payload.response.sum_stgdgg225,
            stgdgg300: action.payload.response.sum_stgdgg300,
            stgdgg400: action.payload.response.sum_stgdgg400,
            stgdgg450: action.payload.response.sum_stgdgg450,
            stgdgg600: action.payload.response.sum_stgdgg600,
            stgdgg800: action.payload.response.sum_stgdgg800,
            stgdgg1000: action.payload.response.sum_stgdgg1000,
            stgdgg1200: action.payload.response.sum_stgdgg1200,
            stgdgg1350: action.payload.response.sum_stgdgg1350,
            stgdgg1500: action.payload.response.sum_stgdgg1500,
            stgdgg1800: action.payload.response.sum_stgdgg1800,
            stgdgg1800: action.payload.response.sum_stgdgg1800,
            sfth:3
        })
        
        return {
          ...state,
          list: action.payload.data,
        };
      },
      StatisticList(state, action) {
       
        action.payload.data.push({
            yf:'合计',
            gdst     : action.payload.response.sum_gdst,
            qlyn     : action.payload.response.sum_qlyn,
            stgdgg110: action.payload.response.sum_stgdgg110,
            stgdgg225: action.payload.response.sum_stgdgg225,
            stgdgg300: action.payload.response.sum_stgdgg300,
            stgdgg400: action.payload.response.sum_stgdgg400,
            stgdgg450: action.payload.response.sum_stgdgg450,
            stgdgg600: action.payload.response.sum_stgdgg600,
            stgdgg800: action.payload.response.sum_stgdgg800,
            stgdgg1000: action.payload.response.sum_stgdgg1000,
            stgdgg1200: action.payload.response.sum_stgdgg1200,
            stgdgg1350: action.payload.response.sum_stgdgg1350,
            stgdgg1500: action.payload.response.sum_stgdgg1500,
            stgdgg1800: action.payload.response.sum_stgdgg1800,
            stgdgg1800: action.payload.response.sum_stgdgg1800,
            sfth:3
        })
        
        return {
          ...state,
          StatisticList: action.payload.data,
        };
      },
    },
  };
  